﻿using System;
using System.Linq;

namespace Solution.BusinessObject
{
    /// <summary>
    /// Provides the most method for common use.
    /// </summary>
    public static class CommonBO
    {
        /// <summary>
        /// Gets or sets default language of site.
        /// </summary>
        private static Language _defaultSiteLanguage;

        /// <summary>
        /// gets or set Master EDM Container of site.
        /// </summary>
        private static MasterEDMContainer _masterEDM;

        /// <summary>
        /// Gets or sets Master EDM Container.
        /// </summary>
        public static MasterEDMContainer MasterEDM
        {
            get
            {
                return _masterEDM ?? new MasterEDMContainer();
            }
            set { _masterEDM = value; }
        }

        /// <summary>
        /// Gets or sets site language.
        /// </summary>
        public static Language DefaultSiteLanguage
        {
            get
            {
                return _defaultSiteLanguage
                       ?? (_defaultSiteLanguage = MasterEDM.Languages
                                                      .FirstOrDefault(t => t.IsDefault == true));
            }
            set { _defaultSiteLanguage = value; }
        }

        /// <summary>
        /// Writes error exception to text file.
        /// </summary>
        public static void WriteLog(Exception exception)
        {
        }
    }
}
